{
  "properties" : { },
  "id" : "copy1735969303340d3807",
  "script" : null,
  "groupId" : "6a869ffd71b240c6a1576faddb094650",
  "name" : "提取图片_批量",
  "createTime" : null,
  "updateTime" : 1741279251982,
  "lock" : null,
  "createBy" : "可辉",
  "updateBy" : "管理员",
  "path" : "tqtp_pl",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": true\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Base64;
import java.io.File;
import log;

Path baseOutputDir = Paths.get("D:/files/img");
//
var files_1 = new File('F:/file/离线网页').listFiles();

for (file1 in files_1) {
    
    for (file2 in new File(file1.getPath()).listFiles()) {

        String dirName = file2.getPath().substring(file2.getPath().lastIndexOf('\\') + 1).replace('.mht','');
        dirName = dirName.replace('sssssssssssssssssssss','');
        Path outputDir = Paths.get(baseOutputDir+"/"+dirName);

        File ff = new File(baseOutputDir+"/"+dirName);
        if(ff.exists() && ff.listFiles().size() > 0){
            log.info('ok '+baseOutputDir+"/"+dirName);
            continue;
        }

        Files.createDirectories(outputDir);
        
        String mhtFilePath = file2.getPath();
        String content = '';
        // 读取.mht文件内容
        try {
            content = new String(Files.readAllBytes(Paths.get(mhtFilePath)));
        } catch(e) {
            log.info('error：'+mhtFilePath);
            continue;
        }
        // 定义正则表达式来匹配base64编码的图片
        Pattern pattern = Pattern.compile(
            "Content-Type:\\s*image/(\\w+)\\s*" + // 匹配图片类型
            "Content-Transfer-Encoding:\\s*base64\\s*" + // 匹配编码方式为base64
            "(?:Content-Location:[^\\r\\n]*\\r?\\n)?\\r?\\n" + // 可选的Content-Location行
            "([\\s\\S]*?)" + // 捕获任意数量的字符直到遇到下一个边界或结束
            "--?(?=\\s*--|\\z)", // 边界结束符或者文件结束
            Pattern.DOTALL | Pattern.CASE_INSENSITIVE
        );
        Matcher matcher = pattern.matcher(content);
        int index = 0;
        while (matcher.find()) {
            String ContentLocation = matcher.group(0).split('\r\n')[2];
            String HttpUrl = ContentLocation.substring(ContentLocation.lastIndexOf(': ') + 1).trim();
            String fileName = HttpUrl.substring(HttpUrl.lastIndexOf('/') + 1);

            String type = matcher.group(1); // 图片类型, 比如 png, jpg 等
            String base64Image = matcher.group(2).trim(); // Base64编码的字符串

            // 如果 Content-Location 包含 /themes/ 则跳过此部分
            if (HttpUrl.contains("/themes/") || HttpUrl.contains("/game/") 
                || HttpUrl.endsWith(".php") || HttpUrl.contains("%")) {
                continue;
            }

            // 创建输出文件路径
            Path outputPath = outputDir.resolve(fileName);

            // 将解码后的图片写入文件
            Files.write(outputPath, Base64.getMimeDecoder().decode(base64Image));
        }

    }

}

return true